part of '../repository.dart';

class _AppStorePurchasedItemDtoFactory {
  const _AppStorePurchasedItemDtoFactory._internal();

  static const _instance = _AppStorePurchasedItemDtoFactory._internal();

  factory _AppStorePurchasedItemDtoFactory() {
    return _instance;
  }

  _AppStorePurchasedItemDto fromJson(Map<String, dynamic> json) {
    final type = json[_kAppStorePurchasedItemTypeKey] as String;

    if (type == _kAppStorePurchasedSubscriptionTypeValue) {
      return _AppStorePurchasedSubscriptionDto.fromJson(json);
    }

    if (type == _kAppStoreOneTimePurchasedItemTypeValue) {
      return _AppStoreOneTimePurchasedItemDto.fromJson(json);
    }

    throw UnimplementedError();
  }
}
